import { useEffect, useRef } from "react";

// input聚焦
const useInputFocus = (active) => {
    const inputRef = useRef(null);
    // 监听input聚焦
    useEffect(() => {
        // 只有在input显示时聚焦，并且只监听 inputActive 改变时触发
        if (active) {
            inputRef.current.focus();
        }
    }, [active]);
    return inputRef;
};

export default useInputFocus;
